package com.zxx.pattern.observerPattern.observer3;

/**
 * 布告板 （观察者 具体类）
 *
 * @author zxx on 2021/3/10
 */
public class CurrentCondituonDisplay implements Observer3, DisplayElement {

    private float temperature;
    private float humidity;
    private Subject3 weatherData;

    public CurrentCondituonDisplay(Subject3 weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this); //注册观察者
    }

    @Override
    public void display() {
        System.out.println("Current conditions:" + temperature + "F degrees and " + humidity + "% humidity");
    }

    @Override
    public void update(float temp, float humidity, float pressure) {
        this.temperature = temp;
        this.humidity = humidity;
        display();
    }
}
